package queries;

import java.sql.SQLException;
import java.sql.Statement;

import entitys.Customer;
import enums.Result;

public class UpdateClientQuery {
	/**
	 * Method for updating database.
	 * This method gets a customer and adds it do database.
	 */
	public static Result exe(Customer c,java.sql.Connection conn)
	{
		Statement stmt;
		try {
			stmt = conn.createStatement();
			stmt.executeUpdate("UPDATE `ccrm`.`customer` SET `firstName`='"+c.getFirstName()+"', `lastName`='"+c.getLastName()+"', `phone`='"+c.getPhone()+"', `email`='"+c.getEmail()+"', `address`='"+c.getAddress()+"', `permit`='"+(c.getPermit()?1:0)+"', `birthdate`='"+c.getBirthdate()+"' WHERE `id`='"+c.getId()+"';");
			
			return Result.OK;
		} catch (SQLException e) {return Result.ERROR;}
	}
}
